package com.baidu.mpks.role.service;

import com.baidu.mpks.permission.dao.PermissionDao;
import com.baidu.mpks.permission.dao.PermissionDataRoleDao;
import com.baidu.mpks.permission.domain.Permission;
import com.baidu.mpks.permission.domain.PermissionDataRole;
import com.baidu.mpks.permission.dto.DataPermissionDto;
import com.baidu.mpks.permission.dto.TreePermissionDto;
import com.baidu.mpks.permission.dto.TypePermissionDto;
import com.baidu.mpks.permission.service.PermissionService;
import com.baidu.mpks.role.dao.RoleDao;
import com.baidu.mpks.role.domain.Role;
import com.baidu.mpks.role.domain.RolePermission;
import com.baidu.mpks.role.dto.RoleDto;
import com.baidu.mpks.tree.domain.UserTreeNode;
import com.baidu.mpks.tree.service.UserTreeService;
import com.baidu.mpks.util.MysqlUtil;
import com.baidu.mpks.utils.CommonUtils;
import com.baidu.mpks.utils.SecurityUtil;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

@Service
public class RoleServiceImpl implements RoleService{

    @Autowired
    RoleDao roleDao;
    @Autowired
    PermissionDataRoleDao permissionDataRoleDao;
    @Autowired
    PermissionDao permissionDao;
    @Autowired
    private SecurityUtil securityUtil;
    @Autowired
    private RoleManageService roleManageService;
    @Autowired
    private UserTreeService userTreeService;
    @Value("${role-config.role.exclude-ids:}")
    private List<Integer> excludeIds;

    public RoleServiceImpl() {
    }

    public List<Role> findByUserId(String userId) {
        return this.roleDao.findByUserId(userId);
    }

    public Set<Integer> findRoleIdsByUserId(String userId) {
        List<Role> roles = this.roleDao.findByUserId(userId);
        Set<Integer> roleIds = new HashSet();
        Iterator var4 = roles.iterator();

        while(var4.hasNext()) {
            Role role = (Role)var4.next();
            roleIds.add(role.getId());
        }

        return roleIds;
    }

    public Set<String> findStringRoleIdsByUserId(String userId) {
        Set<Integer> roleIds = this.findRoleIdsByUserId(userId);
        Set<String> stringRoleIds = new HashSet();
        Iterator var4 = roleIds.iterator();

        while(var4.hasNext()) {
            Integer roleId = (Integer)var4.next();
            stringRoleIds.add(roleId.toString());
        }

        return stringRoleIds;
    }

    public Set<String> findRoleNamesByUserId(String userId) {
        List<Role> roles = this.roleDao.findByUserId(userId);
        Set<String> roleNames = new LinkedHashSet();
        Iterator var4 = roles.iterator();

        while(var4.hasNext()) {
            Role role = (Role)var4.next();
            roleNames.add(role.getRoleName());
        }

        return roleNames;
    }

    public Map<String, Object> getRoleListPage(Integer pageNum, Integer pageSize, String keyword) {
        Map<String, Object> result = new HashMap();
        List<Role> roleList = this.roleDao.findRoleListPageExclude((pageNum - 1) * pageSize, pageSize, MysqlUtil.replaceLikeString(keyword), this.excludeIds);
        if (!roleList.isEmpty() && roleList.size() > 0) {
            Iterator var6 = roleList.iterator();

            while(var6.hasNext()) {
                Role role = (Role)var6.next();
                List<Permission> permissionList = this.roleDao.findPermissionListByRoleId(role.getId());
                role.setPermissionList(permissionList);
            }
        }

        result.put("list", roleList);
        result.put("totalSize", this.roleDao.getTotalPageExclude(MysqlUtil.replaceLikeString(keyword), this.excludeIds));
        return result;
    }

    public Map<String, Object> getRoleList() {
        Map<String, Object> result = new HashMap();
        List<Role> roleList = this.findRoleList();
        result.put("list", roleList);
        return result;
    }

    public List<Role> findRoleList() {
        List<Role> roles = this.roleDao.findRoleList(this.excludeIds);
        return roles;
    }

    public List<Role> findRoleUserList(Integer pageNum, Integer pageSize) {
        List<Role> roles = this.roleDao.findRoleUserList((pageNum - 1) * pageSize, pageSize);
        return roles;
    }

    public List<Role> findRoleListPage(Integer pageNum, Integer pageSize, String keyword) {
        List<Role> roles = this.roleDao.findRoleListPage((pageNum - 1) * pageSize, pageSize, keyword);
        return roles;
    }

    public boolean isExistRoleUser(Integer roleId, String userId) {
        Long total = this.roleDao.isExistRoleUser(roleId, userId);
        boolean flag = false;
        if (total > 0L) {
            flag = true;
        }

        return flag;
    }

    public String generatePropPermissionDataId(String classId, String propId) {
        return classId + "@" + propId;
    }

    @Transactional
    public void addRoleAndPermission(Role role, List<Integer> permissionList, List<TreePermissionDto> treeList, List<TypePermissionDto> typeList) {
        this.roleDao.insert(role);
//        log.info("addRoleAndPermission roleId {}", role.getId());
        this.addDataAndFuncPermission(role, permissionList, treeList, typeList);
    }

    public void addDataAndFuncPermission(Role role, List<Integer> permissionList, List<TreePermissionDto> treeList, List<TypePermissionDto> typeList) {
        this.roleDao.insertRoleOrPermission(role.getId(), permissionList);
        this.addDataPermission(role, treeList, typeList);
    }

    @Transactional
    public void addDataPermission(Role role, List<TreePermissionDto> treeList, List<TypePermissionDto> typeList) {
        Iterator var7;
        String op;
        PermissionDataRole item;
        if (typeList.size() > 0) {
            Iterator var4 = typeList.iterator();

            label78:
            while(true) {
                TypePermissionDto typePermission;
                do {
                    do {
                        if (!var4.hasNext()) {
                            break label78;
                        }

                        typePermission = (TypePermissionDto)var4.next();
                        List<PermissionDataRole> permissionDataList = new ArrayList();
                        if (typePermission.getOp().size() > 0) {
                            var7 = typePermission.getOp().iterator();

                            while(var7.hasNext()) {
                                op = (String)var7.next();
                                item = new PermissionDataRole();
                                item.setDataId(typePermission.getClassId());
                                item.setOp(op);
                                item.setIdType(PermissionService.IDTYPE.TYPE.getName());
                                item.setRoleId(role.getId().toString());
                                item.setUpdateBy(this.securityUtil.getUserIdOrDefault(""));
                                permissionDataList.add(item);
                            }

                            this.permissionDataRoleDao.batchAdd(permissionDataList);
                        }
                    } while(typePermission.getPropIds() == null);
                } while(typePermission.getPropIds().size() <= 0);

                List<PermissionDataRole> permissionPropDataList = new ArrayList();
                Iterator var17 = typePermission.getPropIds().iterator();

                while(var17.hasNext()) {
                    DataPermissionDto propPermission = (DataPermissionDto)var17.next();
                    Iterator var10 = propPermission.getOp().iterator();

                    while(var10.hasNext()) {
                        op = (String)var10.next();
                        item = new PermissionDataRole();
                        item.setDataId(this.generatePropPermissionDataId(typePermission.getClassId(), propPermission.getDataId()));
                        item.setOp(op);
                        item.setIdType(PermissionService.IDTYPE.FIELD.getName());
                        item.setRoleId(role.getId().toString());
                        item.setUpdateBy(this.securityUtil.getUserIdOrDefault(""));
                        permissionPropDataList.add(item);
                    }
                }

                this.permissionDataRoleDao.batchAdd(permissionPropDataList);
            }
        }

        if (treeList.size() > 0) {
            List<PermissionDataRole> treePermissionList = new ArrayList();
            Iterator var14 = treeList.iterator();

            while(var14.hasNext()) {
                TreePermissionDto treePermission = (TreePermissionDto)var14.next();
                var7 = treePermission.getOp().iterator();

                while(var7.hasNext()) {
                    op = (String)var7.next();
                    item = new PermissionDataRole();
                    item.setDataId(treePermission.getDataId());
                    item.setOp(op);
                    item.setIdType(PermissionService.IDTYPE.SOURCE.getName());
                    item.setRoleId(role.getId().toString());
                    item.setUpdateBy(this.securityUtil.getUserIdOrDefault(""));
                    treePermissionList.add(item);
                }
            }

            if (treePermissionList.size() > 0) {
                this.permissionDataRoleDao.batchAdd(treePermissionList);
            }
        }

    }

    @Transactional
    public void addRoleOrUser(Integer roleId, String userId) {
        this.roleDao.insertRoleOrUser(roleId, userId);
    }

    @Transactional
    public void deleteDataAndFuncPermissionByRoleId(Integer roleId) {
        this.roleDao.deleteRoleAndPermissionByRoleId(roleId);
        this.permissionDataRoleDao.deleteByRoleId(String.valueOf(roleId));
    }

    @Transactional
    public void deleteRoleOrUserByRoleId(Integer roleId) {
        this.roleDao.deleteRoleOrUserByRoleId(roleId);
    }

    @Transactional
    public void updateRole(Role role) {
        this.roleDao.update(role);
    }

    @Transactional
    public void updateRoleAndPermission(Role role, List<Integer> permissionList, List<TreePermissionDto> treeList, List<TypePermissionDto> typeList) {
        this.roleDao.update(role);
        this.deleteDataAndFuncPermissionByRoleId(role.getId());
        this.addDataAndFuncPermission(role, permissionList, treeList, typeList);
    }

    @Transactional
    public void updateRoleStatus(Role role) {
        this.roleDao.updateRoleStatus(role);
    }

    @Transactional
    public void deleteRole(Role role) {
        this.roleDao.delete(role);
        this.deleteDataAndFuncPermissionByRoleId(role.getId());
        this.deleteRoleOrUserByRoleId(role.getId());
    }

    public Role findById(int id) {
        return this.roleDao.findById(id);
    }

    public List<RolePermission> findByPermissionCode(String permissionCode) {
        return this.roleDao.findByPermissionCode(permissionCode);
    }

    public List<Role> findByGroupIdAndRoleIdIn(Set<Integer> roleIdList) {
        return this.roleDao.findByGroupIdAndRoleIdIn(roleIdList);
    }

    public int findRoleUserByUserIdAndRoleId(String userId, Set<Integer> roleIds) {
        return this.roleDao.findRoleUserByUserIdAndRoleId(userId, roleIds);
    }

    public Map<String, TreePermissionDto> addTreeOpTypeList(Set<PermissionDataRole> oriTreePermissionList) {
        Map<String, TreePermissionDto> treeMap = new HashMap();
        if (oriTreePermissionList != null) {
            Iterator var3 = oriTreePermissionList.iterator();

            while(var3.hasNext()) {
                PermissionDataRole treeItem = (PermissionDataRole)var3.next();
                TreePermissionDto treePermissionDto = new TreePermissionDto();
                Set<String> op = new HashSet();
                String dataId = treeItem.getDataId();
                if (treeMap.get(treeItem.getDataId()) != null) {
                    op = ((TreePermissionDto)treeMap.get(treeItem.getDataId())).getOp();
                }

                ((Set)op).add(treeItem.getOp());
                treePermissionDto.setOp((Set)op);
                treePermissionDto.setId(treeItem.getId());
                treePermissionDto.setDataId(dataId);
                treePermissionDto.setIdType(treeItem.getIdType());
                treeMap.put(dataId, treePermissionDto);
            }
        }

        return treeMap;
    }

    public Map<String, TypePermissionDto> addTypeOpTypeList(Set<PermissionDataRole> oriTypePermissionList) {
        Map<String, TypePermissionDto> typeMap = new HashMap();
        if (oriTypePermissionList != null) {
            Iterator var3 = oriTypePermissionList.iterator();

            while(var3.hasNext()) {
                PermissionDataRole typeItem = (PermissionDataRole)var3.next();
                TypePermissionDto typePermissionDto = new TypePermissionDto();
                Set<String> op = new HashSet();
                String dataId = typeItem.getDataId();
                if (typeMap.get(typeItem.getDataId()) != null) {
                    op = ((TypePermissionDto)typeMap.get(typeItem.getDataId())).getOp();
                }

                ((Set)op).add(typeItem.getOp());
                typePermissionDto.setOp((Set)op);
                typePermissionDto.setId(typeItem.getId());
                typePermissionDto.setClassId(typeItem.getDataId());
                typePermissionDto.setIdType(typeItem.getIdType());
                typePermissionDto.setPropIds(new ArrayList());
                typeMap.put(dataId, typePermissionDto);
            }
        }

        return typeMap;
    }

    public void exportDataToWorkbook(Workbook workbook) {
        List<Role> roleList = this.findRoleList();
        String[] tableHeads = new String[]{"序号", "角色名", "角色描述", "更新时间", "状态", "权限信息"};
        Sheet sheet = workbook.createSheet("日志");
        Row headRow = sheet.createRow(0);

        int i;
        for(i = 0; i < tableHeads.length; ++i) {
            headRow.createCell(i).setCellValue(tableHeads[i]);
        }

        if (!CollectionUtils.isEmpty(roleList)) {
            i = 1;

            for(int j = 0; i <= roleList.size(); ++i) {
                Role role = (Role)roleList.get(j);
                Row tempRow = sheet.createRow(i);
                tempRow.createCell(0).setCellValue((double)i);
                tempRow.createCell(1).setCellValue(role.getRoleName());
                tempRow.createCell(2).setCellValue(role.getDescription());
                if (null != role.getUpdateTime()) {
                    tempRow.createCell(3).setCellValue(CommonUtils.timestampToDateTimeString((int)(role.getUpdateTime().getTime() / 1000L), (String)null));
                }

                tempRow.createCell(4).setCellValue(role.getStatus());
                String permissionStr = this.formatRoleAndPermissionInfoForAuditLog(role.getId());
                tempRow.createCell(5).setCellValue(permissionStr);
                ++j;
            }
        }

        workbook.setSheetName(0, "角色清单");
    }

    public void downWorkBookToPC(HttpServletResponse response, Workbook workbook, String fileName) throws IOException {
        response.setHeader("content-Disposition", "attachment;filename=" + new String(fileName.getBytes(StandardCharsets.UTF_8), "ISO8859-1"));
        response.setContentType("application/ynd.ms-excel;charset=UTF-8");
        OutputStream stream = response.getOutputStream();
        workbook.write(stream);
        stream.flush();
        stream.close();
    }

    public List<Role> findByIds(List<Integer> roleIds) {
        return this.roleDao.findByIds(roleIds);
    }

    public RoleDto findDataPermissionInfoByRoleId(int roleId) {
        RoleDto roleDto = new RoleDto();
        Set<PermissionDataRole> openPermissionList = this.permissionDataRoleDao.getOpenDataId();
        Map<String, Set<PermissionDataRole>> openPermissionMap = new HashMap();
        openPermissionList.forEach((itemx) -> {
            Set<PermissionDataRole> permissionList = new HashSet();
            if (openPermissionMap.get(itemx.getIdType()) != null) {
                permissionList = (Set)openPermissionMap.get(itemx.getIdType());
            }

            ((Set)permissionList).add(itemx);
            openPermissionMap.put(itemx.getIdType(), permissionList);
        });
        Set<PermissionDataRole> allPermissionList = this.permissionDataRoleDao.getByRoleId(String.valueOf(roleId));
        Map<String, Set<PermissionDataRole>> allPermissionMap = new HashMap();
        allPermissionList.forEach((itemx) -> {
            Set<PermissionDataRole> permissionList = new HashSet();
            if (allPermissionMap.get(itemx.getIdType()) != null) {
                permissionList = (Set)allPermissionMap.get(itemx.getIdType());
            }

            ((Set)permissionList).add(itemx);
            allPermissionMap.put(itemx.getIdType(), permissionList);
        });
        Set<TreePermissionDto> treePermissionList = new HashSet();
        Set<PermissionDataRole> oriTreePermissionList = (Set)allPermissionMap.get(PermissionService.IDTYPE.SOURCE.getName());
        Map<String, TreePermissionDto> treeMap = this.addTreeOpTypeList(oriTreePermissionList);
        Map<String, TreePermissionDto> openTreeMap = this.addTreeOpTypeList((Set)openPermissionMap.get(PermissionService.IDTYPE.SOURCE.getName()));
        Map<String, TreePermissionDto> allTreeMap = new HashMap();
        Set<String> allTreeDataIdList = new HashSet();
        allTreeDataIdList.addAll(openTreeMap.keySet());
        allTreeDataIdList.addAll(treeMap.keySet());

        Iterator var13;
        String dataId;
        TreePermissionDto temp;
        for(var13 = allTreeDataIdList.iterator(); var13.hasNext(); allTreeMap.put(dataId, temp)) {
            dataId = (String)var13.next();
            temp = new TreePermissionDto();
            if (openTreeMap.get(dataId) != null && treeMap.get(dataId) != null) {
                try {
                    BeanUtils.copyProperties(temp, openTreeMap.get(dataId));
                } catch (InvocationTargetException | IllegalAccessException var37) {
//                    log.error(var37.getMessage());
                }

                Set<String> opList = ((TreePermissionDto)treeMap.get(dataId)).getOp();
                opList.addAll(((TreePermissionDto)openTreeMap.get(dataId)).getOp());
                temp.setOp(opList);
            } else if (openTreeMap.get(dataId) != null) {
                try {
                    BeanUtils.copyProperties(temp, openTreeMap.get(dataId));
                } catch (InvocationTargetException | IllegalAccessException var36) {
//                    log.error(var36.getMessage());
                }
            } else if (treeMap.get(dataId) != null) {
                try {
                    BeanUtils.copyProperties(temp, treeMap.get(dataId));
                } catch (InvocationTargetException | IllegalAccessException var35) {
//                    log.error(var35.getMessage());
                }
            }
        }

        var13 = allTreeMap.values().iterator();

        while(var13.hasNext()) {
            TreePermissionDto item = (TreePermissionDto)var13.next();
            treePermissionList.add(item);
        }

        roleDto.setTreePermissionList(treePermissionList);
        Set<TypePermissionDto> typePermissionList = new HashSet();
        Set<PermissionDataRole> oriTypePermissionList = (Set)allPermissionMap.get(PermissionService.IDTYPE.TYPE.getName());
        Map<String, TypePermissionDto> typeMap = this.addTypeOpTypeList(oriTypePermissionList);
        Map<String, TypePermissionDto> openTypeMap = this.addTypeOpTypeList((Set)openPermissionMap.get(PermissionService.IDTYPE.TYPE.getName()));
        Map<String, TypePermissionDto> allTypeMap = new HashMap();
        Set<String> allTypeDataIdList = new HashSet();
        allTypeDataIdList.addAll(openTypeMap.keySet());
        allTypeDataIdList.addAll(typeMap.keySet());

        String dataId1;
        TypePermissionDto temp1;
        for(Iterator var19 = allTypeDataIdList.iterator(); var19.hasNext(); allTypeMap.put(dataId1, temp1)) {
            dataId1 = (String)var19.next();
            temp1 = new TypePermissionDto();
            if (openTypeMap.get(dataId1) != null && typeMap.get(dataId1) != null) {
                try {
                    BeanUtils.copyProperties(temp1, openTypeMap.get(dataId1));
                } catch (InvocationTargetException | IllegalAccessException var34) {
//                    log.error(var34.getMessage());
                }

                Set<String> opList = ((TypePermissionDto)typeMap.get(dataId1)).getOp();
                opList.addAll(((TypePermissionDto)openTypeMap.get(dataId1)).getOp());
                temp1.setOp(opList);
            } else if (openTypeMap.get(dataId1) != null) {
                try {
                    BeanUtils.copyProperties(temp1, openTypeMap.get(dataId1));
                } catch (InvocationTargetException | IllegalAccessException var33) {
//                    log.error(var33.getMessage());
                }
            } else if (typeMap.get(dataId1) != null) {
                try {
                    BeanUtils.copyProperties(temp1, typeMap.get(dataId1));
                } catch (InvocationTargetException | IllegalAccessException var32) {
//                    log.error(var32.getMessage());
                }
            }
        }

        Set<PermissionDataRole> oriPropPermissionList = (Set)allPermissionMap.get(PermissionService.IDTYPE.FIELD.getName());
        Map<String, Set<String>> propOpMap = new HashMap();
        Map<String, List<DataPermissionDto>> propPermissionMap = new HashMap();
        Iterator var46;
        if (oriPropPermissionList != null) {
            var46 = oriPropPermissionList.iterator();

            while(var46.hasNext()) {
                PermissionDataRole item = (PermissionDataRole)var46.next();
                String classPropId = item.getDataId();
                String[] classPropIdArr = classPropId.split("@");
                String classId = classPropIdArr[0];
                String propId = classPropIdArr[1];
                TypePermissionDto classPermission = (TypePermissionDto)allTypeMap.get(classId);
                if (classPermission == null) {
                    classPermission = new TypePermissionDto();
                    classPermission.setClassId(classId);
                    classPermission.setOp(new HashSet());
                    classPermission.setIdType(PermissionService.IDTYPE.TYPE.getName());
                }

                DataPermissionDto propPermission = new DataPermissionDto();
                propPermission.setDataId(propId);
                Set<String> op = new HashSet();
                if (propOpMap.get(classPropId) != null) {
                    op = (Set)propOpMap.get(classPropId);
                }

                ((Set)op).add(item.getOp());
                propOpMap.put(classPropId, op);
                propPermission.setOp((Set)op);
                List<DataPermissionDto> propPermissionList = new ArrayList();
                if (classPermission.getPropIds() != null) {
                    propPermissionList = classPermission.getPropIds();
                }

                if (propPermissionMap.get(classPropId) == null) {
                    ((List)propPermissionList).add(propPermission);
                }

                propPermissionMap.put(classPropId, propPermissionList);
                classPermission.setPropIds((List)propPermissionList);
                allTypeMap.put(classId, classPermission);
            }
        }

        var46 = allTypeMap.values().iterator();

        while(var46.hasNext()) {
            TypePermissionDto item = (TypePermissionDto)var46.next();
            typePermissionList.add(item);
        }

        roleDto.setTypePermissionList(typePermissionList);
        return roleDto;
    }

    public String formatRoleAndPermissionInfoForAuditLog(Integer roleId) {
        try {
            RoleDto role = this.roleManageService.findPermissionInfoByRoleId(roleId);
            List<UserTreeNode> treeNodes = this.userTreeService.getTreeNodes();
            Map<String, UserTreeNode> idTreeMap = (Map)treeNodes.stream().collect(Collectors.toMap((o) -> {
                return "" + o.getId();
            }, Function.identity()));
            UserTreeNode defaultTree = new UserTreeNode();
            String permissionsStr = (String)role.getPermissionList().stream().map((o) -> {
                return o.getId() + "-" + o.getName();
            }).collect(Collectors.joining(","));
            String treePermissionsStr = (String)role.getTreePermissionList().stream().map((o) -> {
                return ((UserTreeNode)idTreeMap.getOrDefault(o.getDataId(), defaultTree)).getName() + "：" + this.formatToOpNames(o.getOp());
            }).collect(Collectors.joining(","));
            String typePermissionsStr = (String)role.getTypePermissionList().stream().map((o) -> {
                return o.getClassId() + "：" + this.formatToOpNames(o.getOp()) + "（" + (String)o.getPropIds().stream().map((p) -> {
                    return p.getDataId() + "：" + this.formatToOpNames(p.getOp());
                }).collect(Collectors.joining(",")) + "）";
            }).collect(Collectors.joining(","));
            return String.format("%s-%s（菜单权限：<%s>，知识树权限：<%s>，类目权限：<%s>）", role.getId(), role.getRoleName(), permissionsStr, treePermissionsStr, typePermissionsStr);
        } catch (Throwable var9) {
//            throw var9;
        }
        return "";
    }

    private String formatToOpNames(Set<String> ops) {
        return ops == null ? null : String.join(",", this.convertToOpNames(ops));
    }

    private Set<String> convertToOpNames(Set<String> ops) {
        return ops == null ? null : (Set)ops.stream().map(this::convertToOpName).collect(Collectors.toSet());
    }

    private String convertToOpName(String op) {
        if (op == null) {
            return null;
        } else {
            byte var3 = -1;
            switch(op.hashCode()) {
                case 114:
                    if (op.equals("r")) {
                        var3 = 0;
                    }
                    break;
                case 3493:
                    if (op.equals("mr")) {
                        var3 = 1;
                    }
                    break;
                case 3665:
                    if (op.equals("sd")) {
                        var3 = 2;
                    }
                    break;
                case 3670:
                    if (op.equals("si")) {
                        var3 = 3;
                    }
                    break;
                case 3676:
                    if (op.equals("so")) {
                        var3 = 4;
                    }
            }

            switch(var3) {
                case 0:
                    return "搜索";
                case 1:
                    return "管理端查看";
                case 2:
                    return "下载";
                case 3:
                    return "正文";
                case 4:
                    return "概要";
                default:
                    return op;
            }
        }
    }
}
